package com.peakmain.wanandroid.activity;

import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.View;

import com.blankj.utilcode.util.SPUtils;
import com.peakmain.wanandroid.R;
import com.peakmain.wanandroid.loginmodule.LoginActivity;
import com.peakmain.wanandroid.loginmodule.constant.LoginConstant;
import com.peakmain.wanandroid.netmodule.base.BaseActivity;

/**
 * author: peakmain
 * createdata：2019/7/10
 * mail: 2726449200@qq.com
 * desiption:
 */
public class SplashActivity extends BaseActivity {
    private Handler mHandler = new Handler(Looper.getMainLooper());

    @Override
    protected int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initView() {
        // 全屏显示
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                String account = SPUtils.getInstance().getString(LoginConstant.ACCOUNT);
                if(!TextUtils.isEmpty(account)){
                    startActivity(new Intent(SplashActivity.this,MainActivity.class));
                }else{
                    startActivity(new Intent(SplashActivity.this, LoginActivity.class));
                }

                finish();

            }
        }, 1500);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mHandler.removeCallbacksAndMessages(null);
    }
}
